﻿using System;
namespace Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="KOLAAsiOtsing", Namespace="http://producers.etoimik.xtee.riik.ee/producer/etoimik", Target=typeof(KOLAAsiOtsing))]
    public class KOLAAsiOtsingSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IKOLAAsiOtsing clazz;
        
        public KOLAAsiOtsingSerializer(IKOLAAsiOtsing clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            if (clazz.AsjaKategooria!=null) {
                Writer.WriteStartElement("AsjaKategooria");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsjaKategooria))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsjaLiik!=null) {
                Writer.WriteStartElement("AsjaLiik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsjaLiik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.AsjaNumber!=null) {
                Writer.WriteStartElement("AsjaNumber");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.AsjaNumber))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.KasAvalik!=null) {
                Writer.WriteStartElement("KasAvalik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "boolean");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdBoolean(((bool)(clazz.KasAvalik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kohtunik!=null) {
                Writer.WriteStartElement("Kohtunik");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kohtunik))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Kohus!=null) {
                Writer.WriteStartElement("Kohus");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Kohus))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LahendiKPAlates!=null) {
                Writer.WriteStartElement("LahendiKPAlates");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.LahendiKPAlates))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.LahendiKPKuni!=null) {
                Writer.WriteStartElement("LahendiKPKuni");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "dateTime");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDateTime(((System.DateTime)(clazz.LahendiKPKuni))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Marksonad!=null) {
                Writer.WriteStartElement("Marksonad");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Marksonad))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MenetlusaluneOsaline!=null) {
                Writer.WriteStartElement("MenetlusaluneOsaline");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MenetlusaluneOsaline))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.MuuOsaline!=null) {
                Writer.WriteStartElement("MuuOsaline");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.MuuOsaline))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.Osaline!=null) {
                Writer.WriteStartElement("Osaline");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Osaline))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.SeaduseSate!=null) {
                Writer.WriteStartElement("SeaduseSate");
                global::Xtee.Core.SerializationMetadata metaSeaduseSate = this.GetMetaData(clazz.SeaduseSate);
                Writer.WriteTypeAttribute(metaSeaduseSate.TypeQualifiedName.Namespace, metaSeaduseSate.TypeQualifiedName.Name);
                metaSeaduseSate.NewSerializer(clazz.SeaduseSate).WriteXml(Writer);
                Writer.WriteEndElement();
            }
            if (clazz.TulemusedAlates!=null) {
                Writer.WriteStartElement("TulemusedAlates");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.TulemusedAlates))).ToString());
                Writer.WriteEndElement();
            }
            if (clazz.TulemusedKuni!=null) {
                Writer.WriteStartElement("TulemusedKuni");
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "int");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInt(((int)(clazz.TulemusedKuni))).ToString());
                Writer.WriteEndElement();
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="AsjaKategooria") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsjaKategooria = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AsjaKategooria")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AsjaLiik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsjaLiik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AsjaLiik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="AsjaNumber") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.AsjaNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("AsjaNumber")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="KasAvalik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KasAvalik = new global::Xtee.Core.Schema.XsdBoolean(Reader.ReadElementString("KasAvalik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kohtunik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kohtunik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kohtunik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Kohus") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Kohus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Kohus")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LahendiKPAlates") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LahendiKPAlates = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("LahendiKPAlates")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="LahendiKPKuni") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.LahendiKPKuni = new global::Xtee.Core.Schema.XsdDateTime(Reader.ReadElementString("LahendiKPKuni")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Marksonad") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Marksonad = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Marksonad")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MenetlusaluneOsaline") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MenetlusaluneOsaline = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MenetlusaluneOsaline")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="MuuOsaline") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.MuuOsaline = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("MuuOsaline")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="Osaline") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Osaline = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("Osaline")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="SeaduseSate") {
                if ((Reader.IsElementNil() == false)) {
                    global::Xtee.Core.SerializationMetadata metaSeaduseSate = this.GetMetaData<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IKOLASeaduseSate>(Reader, "KOLASeaduseSate", "http://producers.etoimik.xtee.riik.ee/producer/etoimik");
                    clazz.SeaduseSate = metaSeaduseSate.NewEntity<global::Producers.Etoimik.Xtee.Riik.Ee.Producer.Etoimik.IKOLASeaduseSate>();
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("SeaduseSate");
                        metaSeaduseSate.NewSerializer(clazz.SeaduseSate).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TulemusedAlates") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TulemusedAlates = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("TulemusedAlates")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            if (Reader.LocalName=="TulemusedKuni") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.TulemusedKuni = new global::Xtee.Core.Schema.XsdInt(Reader.ReadElementString("TulemusedKuni")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
        }
    }
}
